﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace App.Validate
{
    public class AndCompositeValidator: CompositeValidator
    {
        public AndCompositeValidator(string messageTemplate,IEnumerable<Validator> validators)
            : base(messageTemplate,validators)
        { }

        public override ValidationError Validate(object objectToValidate)
        {
            foreach (var validator in this.Validators)
            {
                if (null != validator.Validate(objectToValidate))
                {
                    return this.CreateValidationError(objectToValidate);
                }
            }
            return null;
        }
    }
}
